"""
-------------------------------
- File_Name: __init__.py.py
- Date: 2025/2/11
- Author: yangzhide
- Email: xxzjyzd@126.com
- Description: 统一响应模型
-------------------------------
"""
from typing import TypeVar,Generic

from pydantic import BaseModel

# 定义一个类型变量，用于泛型
T = TypeVar('T')

class Extra(BaseModel,Generic[T]):
    records: list[T]
    total: int | None = None
    current: int | None = None
    size: int | None = None

class BaseResponse(BaseModel,Generic[T]):
    """响应数据，无分页"""
    code: int | str = 200
    data: T | list[T] | None  # data 可能是条数据或列表
    msg: str

class BaseResponseExtra(BaseModel,Generic[T]):
    """响应数据，有分页"""
    code: int | str = 200
    data: Extra[T]
    msg: str
